<template>
  <div class="container">
    <el-card shadow="always">
      <el-row :gutter="20">
        <el-col :span="6">
          <el-input
            maxlength="50"
            v-model="query.searchValue"
            clearable
            placeholder="请输入被检查单位名称"
          ></el-input>
        </el-col>
        <!-- <el-col :span="4">
          <el-select v-model="value" placeholder="请选择考核结果" clearable>
            <el-option
              v-for="item in options"
              :key="item"
              :label="item"
              :value="item"
            >
            </el-option>
          </el-select>
        </el-col> -->
        <el-col :span="2">
          <el-button type="primary" @click="query.page=1;getList()">查询</el-button>
        </el-col>
      </el-row>
      <rz-height></rz-height>

      <el-table :data="tableData" border style="width: 100%">
        <el-table-column prop="supUnitName" label="被查单位">
        </el-table-column>
        <el-table-column prop="checkDateStr" label="检查日期">
        </el-table-column>
        <el-table-column prop="checkUserName" label="检查人员"> </el-table-column>
        <el-table-column prop="checkContent" label="检查情况"> </el-table-column>
        <el-table-column prop="" label="操作">
          <template slot-scope="scope">
            <el-button size="mini" type="primary" @click="view(scope.row)"
              >查看</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <pagination
        :total="total"
        @pagination="getList"
        :page.sync="query.page"
      />
    </el-card>
    <rz-dialog
      :dialogVisible.sync="dialogVisible"
      :isShowConfirm="false"
      title="查看检查台账"
    >
      <el-form label-width="120px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="检查时间">
              {{ data.checkDate }}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="检查人员">
              {{ data.checkUserName }}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="检查单位"> {{ data.supUnitName }} </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="检查情况">
              {{ data.checkContent }}
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="现场照片">
          <el-image
            v-for="(index, item) in data.imgList"
            :key="item"
            style="width: 150px; height: 150px;margin-right:10px"
            :src="index.fileUrl"
            fit="cover"
            :preview-src-list="data.imgList.map((x) => x.fileUrl)"
          ></el-image>
        </el-form-item>
      </el-form>
    </rz-dialog>
  </div>
</template>
<script>
//
import {
  checkFindListByCondition,
  checkFindResponseById,
} from "@/api/modules/workstation";
export default {
  // props:[],
  // 页面加载
  created() {
    this.getList();
  },
  // 页面加载完成
  mounted() {},
  //实例销毁之前
  beforeDestroy() {},
  //实例销毁后
  destroyed() {},
  data() {
    return {
      //   options: ["合格", "不需要考核"],
      query: {
        endMeetingTime: "",
        isPage: 0,
        page: 1,
        pageSize: 10,
        searchValue: "",
        // sessionStorage.getItem("workId")
        workStationId: sessionStorage.getItem("workId"),
      },
      tableData: [],
      total: 0,
      dialogVisible: false,
      data: {},
    };
  },
  // 方法
  methods: {
    getList() {
      checkFindListByCondition(this.query).then((res) => {
        // res.data.forEach((x) => {
        //   for (const key in x) {
        //     if (!x[key]) {
        //       x[key] = "--";
        //     }
        //   }
        // });
        this.total = res.totalCount;
        this.tableData = res.data;
      });
    },
    view(e) {
      checkFindResponseById({
        params: { id: e.id },
      }).then((res) => {
        this.data = res.data;
        this.dialogVisible = true;
      });
    },
  },
};
</script>

<style lang="scss" scoped>
</style>